package by.epam.trenings.vkphotorest.utils;

import by.epam.trenings.vkphotorest.imageLoader.ImageLoader;
import by.epam.trenings.vkphotorest.service.ServiceHelper;
import by.epam.trenings.vkphotorest.utils.context.ContextHolder;
import android.app.Application;

public class TaskApplication extends Application {

	private static ImageLoader sImageLoader;

	private static ServiceHelper sServiceHelper;

	@Override
	public void onCreate() {
		super.onCreate();
		ContextHolder.getInstance().setContext(this);
		initImageLoader();
		initServiceHelper();
	}

	private void initServiceHelper() {
		if (sServiceHelper == null) {
			sServiceHelper = new ServiceHelper(this);
		}
	}

	private void initImageLoader() {
		if (sImageLoader == null) {
			sImageLoader = new ImageLoader();
		}
	}

	public static ServiceHelper getServiceHelper() {
		return sServiceHelper;
	}

	public static ImageLoader getImageLoader() {
		return sImageLoader;
	}
}
